package com.xxx.client.android.dialog;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;

import com.xxx.client.android.activity.HistoryListActivity;
import com.xxx.client.android.db.Database;
import com.xxx.client.android.db.DatabaseImpl;
import com.xxx.client.android.db.History;

public class HistoryListLoadingDialog extends
		LoadingDialog<Void, ArrayList<History>> {

	public HistoryListLoadingDialog(Activity activity, int loadingMsg,
			int failMsg) {
		super(activity, loadingMsg, failMsg);
	}

	/**
	 * @param params
	 *            params[0]:keyword params[1]:type params[2]:submenuId
	 *            params[3]:submenuName
	 * */
	@Override
	public ArrayList<History> doInBackground(Void... params) {

		Database database = new DatabaseImpl(mActivity);
		ArrayList<History> historyList = null;

		try {
			historyList = database.getHistoryList();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		return historyList;

	}

	@Override
	public void doStuffWithResult(ArrayList<History> historyList) {

		Intent intent = new Intent(mActivity, HistoryListActivity.class);

		intent.putExtra("historyList", historyList);
		mActivity.startActivity(intent);
	}

}
